from pyecharts.charts import Bar, Timeline
from pyecharts.globals import ThemeType
from pyecharts.options import *

bar2 = Bar()
bar2.add_xaxis(["中国", "美国", "英国"])
bar2.add_yaxis("GDP", [30, 20, 10], label_opts=LabelOpts(position="right"))
bar2.reversal_axis()
bar3 = Bar()
bar3.add_xaxis(["中国", "美国", "英国"])
bar3.add_yaxis("GDP", [50, 30, 20], label_opts=LabelOpts(position="right"))
bar3.reversal_axis()
timeline = Timeline(
    {"theme":ThemeType.LIGHT}
)
timeline.add(bar2, "2021年GDP")
timeline.add(bar3, "2022年GDP")
timeline.add_schema(
    play_interval=1000,
    is_timeline_show=True,
    is_auto_play=True,
    is_loop_play=True
)
timeline.render("基础柱状图-时间线.html")